package com.qubuyer.business.home.model

import com.qubuyer.repository.entitys.HomeGoodEntity
import com.qubuyer.business.home.presenter.ILimitBuyPresenter
import com.qubuyer.constant.NetConstant
import com.qubyer.okhttputil.callback.HttpCallback
import com.qubyer.okhttputil.helper.HttpInvoker

class LimitBuyModel(private var mPresenter: ILimitBuyPresenter?) : ILimitBuyModel {
    private val pageNo = 1

    override fun loadLimitBuyData() {
        HttpInvoker.createBuilder(NetConstant.GET_HOME_FLASH_SALE_POST)
                .setMethodType(HttpInvoker.HTTP_REQUEST_METHOD_POST)
                .setClz(Array<HomeGoodEntity>::class.java)
                .build().sendAsyncHttpRequest(HttpCallback { serverResponse, requestParams, requestUrl ->
                    if (null == mPresenter) return@HttpCallback
                    mPresenter!!.onLoadLimitBuyData(serverResponse)
                })
    }

    override fun destroy() {
        mPresenter = null
    }
}